package com.mfm.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Auther: MFM
 * @Date: 2022/8/2 - 08 - 02 - 20:50
 * @version: 1.0
 */

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex) {
        //记录日志（错误堆栈）
        //发送邮件给开发人员
        //发送短信给运维人员
        return new Result(code.SYSTEM_UNKOWN_ERR, null);
    }

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException ex) {
        return new Result(code.PROJECT_BUSINESS_ERR, null);
    }

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException ex) {
        //记录日志（错误堆栈）
        //发送邮件给开发人员
        //发送短信给运维人员
        return new Result(code.SYSTEM_TIMEOUT_ERR, null);
    }

}
